//
//  UIFont+TYTheme.m
//  TYOEMConfig
//
//  Created by 盲僧 on 2020/7/13.
//

#import "UIFont+TYTheme.h"
#import "objc/runtime.h"
//#import "NSObject+TYSwizzle.h"
#import "TYTheme.h"
@implementation UIFont (TYTheme)
+ (void)load
{
//    [self ty_swizzleClassMethod: @selector(systemFontOfSize:) with:@selector(ty_themeSystemFontOfSize:)];
//    [self ty_swizzleClassMethod:@selector(boldSystemFontOfSize:) with:@selector(ty_themeBoldSystemFontOfSize:)];
//    [self ty_swizzleClassMethod:@selector(systemFontOfSize:weight:) with:@selector(ty_themeSystemFontOfSize:weight:)];
}

+ (UIFont *)ty_themeSystemFontOfSize:(CGFloat)fontSize
{
    UIFont *systemFont = [UIFont systemFontOfSize:fontSize weight:UIFontWeightRegular];
    if (!systemFont) {
        systemFont = [UIFont ty_themeSystemFontOfSize:fontSize];
    }
    return systemFont;
}

+ (UIFont *)ty_themeBoldSystemFontOfSize:(CGFloat)fontSize
{
    UIFont *blodSystemFont = [UIFont systemFontOfSize:fontSize weight:UIFontWeightBold];
    if (!blodSystemFont) {
        blodSystemFont = [UIFont ty_themeBoldSystemFontOfSize:fontSize];
    }
    return blodSystemFont;
}

+ (UIFont *)ty_themeSystemFontOfSize:(CGFloat)fontSize weight:(UIFontWeight)weight
{
    UIFont *systemFont;
    if (weight == UIFontWeightBold || weight == UIFontWeightHeavy || weight == UIFontWeightBlack) {
        systemFont = [UIFont fontWithName:TYTheme.theme.appBoldFont size:fontSize];
    } else {
        systemFont = [UIFont fontWithName:TYTheme.theme.appFont size:fontSize];
    }
    if (!systemFont) {
        systemFont = [UIFont ty_themeSystemFontOfSize:fontSize weight:weight];
    }
    return systemFont;
}

@end
